{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Company</th>\n",
       "      <th>Name</th>\n",
       "      <th>Age</th>\n",
       "      <th>Height</th>\n",
       "      <th>Weight</th>\n",
       "      <th>Salary</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>A</td>\n",
       "      <td>a1</td>\n",
       "      <td>47</td>\n",
       "      <td>188</td>\n",
       "      <td>63.7</td>\n",
       "      <td>25819</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>A</td>\n",
       "      <td>a3</td>\n",
       "      <td>39</td>\n",
       "      <td>172</td>\n",
       "      <td>55.9</td>\n",
       "      <td>21983</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>A</td>\n",
       "      <td>a4</td>\n",
       "      <td>43</td>\n",
       "      <td>158</td>\n",
       "      <td>62.5</td>\n",
       "      <td>21755</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>A</td>\n",
       "      <td>a6</td>\n",
       "      <td>42</td>\n",
       "      <td>182</td>\n",
       "      <td>76.9</td>\n",
       "      <td>17354</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>A</td>\n",
       "      <td>a7</td>\n",
       "      <td>49</td>\n",
       "      <td>171</td>\n",
       "      <td>94.6</td>\n",
       "      <td>6177</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  Company Name  Age  Height  Weight  Salary\n",
       "0       A   a1   47     188    63.7   25819\n",
       "1       A   a3   39     172    55.9   21983\n",
       "2       A   a4   43     158    62.5   21755\n",
       "3       A   a6   42     182    76.9   17354\n",
       "4       A   a7   49     171    94.6    6177"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "import time\n",
    "df = pd.read_csv('data/Employee1.csv').head()\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "lst=[]\n",
    "for i in range(10):\n",
    "    lst.append(pd.Series(np.random.randn(10),name=str(i)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1.188079</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>-0.835067</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>-0.155890</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>-0.202824</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0.080246</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>-1.957082</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>1.455365</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>-0.845458</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>0.520818</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>0.003451</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          0\n",
       "0  1.188079\n",
       "1 -0.835067\n",
       "2 -0.155890\n",
       "3 -0.202824\n",
       "4  0.080246\n",
       "5 -1.957082\n",
       "6  1.455365\n",
       "7 -0.845458\n",
       "8  0.520818\n",
       "9  0.003451"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>a</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1.188079</td>\n",
       "      <td>-1.137554</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>-0.835067</td>\n",
       "      <td>-0.974172</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>-0.155890</td>\n",
       "      <td>-1.420269</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>-0.202824</td>\n",
       "      <td>0.292303</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0.080246</td>\n",
       "      <td>0.651617</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>-1.957082</td>\n",
       "      <td>0.174378</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>1.455365</td>\n",
       "      <td>-0.813003</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>-0.845458</td>\n",
       "      <td>1.727866</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>0.520818</td>\n",
       "      <td>-0.819755</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>0.003451</td>\n",
       "      <td>-1.876426</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          0         a\n",
       "0  1.188079 -1.137554\n",
       "1 -0.835067 -0.974172\n",
       "2 -0.155890 -1.420269\n",
       "3 -0.202824  0.292303\n",
       "4  0.080246  0.651617\n",
       "5 -1.957082  0.174378\n",
       "6  1.455365 -0.813003\n",
       "7 -0.845458  1.727866\n",
       "8  0.520818 -0.819755\n",
       "9  0.003451 -1.876426"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "def assignSeries(lst):\n",
    "    d=pd.DataFrame(lst[0])\n",
    "    display(d)\n",
    "    l=list(range(1,len(lst)))\n",
    "    for i in range(1,len(lst)):\n",
    "        s=str(i)\n",
    "        d=d.assign(a=lst[i]) #SyntaxError: keyword can't be an expression\n",
    "    return d\n",
    "assignSeries(lst)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "def my_assign(self, **kwargs):\n",
    "    data = self.copy()\n",
    "    for k, v in kwargs.items():\n",
    "        data[k] = com.apply_if_callable(v, data)\n",
    "    return data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1.188079</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>-0.835067</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>-0.155890</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>-0.202824</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0.080246</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>-1.957082</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>1.455365</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>-0.845458</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>0.520818</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>0.003451</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          0\n",
       "0  1.188079\n",
       "1 -0.835067\n",
       "2 -0.155890\n",
       "3 -0.202824\n",
       "4  0.080246\n",
       "5 -1.957082\n",
       "6  1.455365\n",
       "7 -0.845458\n",
       "8  0.520818\n",
       "9  0.003451"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "d=pd.DataFrame(lst[0])\n",
    "d.my_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Gender</th>\n",
       "      <th>Height</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>M</td>\n",
       "      <td>173</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>F</td>\n",
       "      <td>192</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  Gender  Height\n",
       "0      M     173\n",
       "1      F     192"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_combine_1 = df.loc[:1,['Gender','Height']].copy()\n",
    "df_combine_2 = df.loc[10:11,['Gender','Height']].copy()\n",
    "df_combine_1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Gender</th>\n",
       "      <th>Height</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>M</td>\n",
       "      <td>161</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>F</td>\n",
       "      <td>175</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Gender  Height\n",
       "10      M     161\n",
       "11      F     175"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_combine_2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0       M\n",
      "1       F\n",
      "10    NaN\n",
      "11    NaN\n",
      "Name: Gender, dtype: object\n",
      "0     173.0\n",
      "1     192.0\n",
      "10      NaN\n",
      "11      NaN\n",
      "Name: Height, dtype: float64\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Gender</th>\n",
       "      <th>Height</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Gender Height\n",
       "0     NaN    NaN\n",
       "1     NaN    NaN\n",
       "10    NaN    NaN\n",
       "11    NaN    NaN"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_combine_1 = df.loc[:1,['Gender','Height']].copy()\n",
    "df_combine_2 = df.loc[10:11,['Gender','Height']].copy()\n",
    "df_combine_1.combine(df_combine_2,lambda x,y:print(x))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.49282360076904297\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th>judge</th>\n",
       "      <th>Judge_1</th>\n",
       "      <th>Judge_2</th>\n",
       "      <th>Judge_3</th>\n",
       "      <th>Judge_4</th>\n",
       "      <th>Judge_5</th>\n",
       "      <th>Judge_6</th>\n",
       "      <th>Judge_7</th>\n",
       "      <th>Judge_8</th>\n",
       "      <th>Judge_9</th>\n",
       "      <th>Judge_10</th>\n",
       "      <th>...</th>\n",
       "      <th>Judge_291</th>\n",
       "      <th>Judge_292</th>\n",
       "      <th>Judge_293</th>\n",
       "      <th>Judge_294</th>\n",
       "      <th>Judge_295</th>\n",
       "      <th>Judge_296</th>\n",
       "      <th>Judge_297</th>\n",
       "      <th>Judge_298</th>\n",
       "      <th>Judge_299</th>\n",
       "      <th>Judge_300</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>index</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>77.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>...</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>...</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>...</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>...</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>...</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-1.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 300 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "judge  Judge_1  Judge_2  Judge_3  Judge_4  Judge_5  Judge_6  Judge_7  Judge_8  \\\n",
       "index                                                                           \n",
       "1         -1.0     -1.0     -1.0     -1.0     77.0     -1.0     -1.0     -1.0   \n",
       "2         -1.0     -1.0     -1.0     -1.0     -1.0     -1.0     -1.0     -1.0   \n",
       "3         -1.0     -1.0     -1.0     -1.0     -1.0     -1.0     -1.0     -1.0   \n",
       "4         -1.0     -1.0     -1.0     -1.0     -1.0     -1.0     -1.0     -1.0   \n",
       "5         -1.0     -1.0     -1.0     -1.0     -1.0     -1.0     -1.0     -1.0   \n",
       "\n",
       "judge  Judge_9  Judge_10  ...  Judge_291  Judge_292  Judge_293  Judge_294  \\\n",
       "index                     ...                                               \n",
       "1         -1.0      -1.0  ...       -1.0       -1.0       -1.0       -1.0   \n",
       "2         -1.0      -1.0  ...       -1.0       -1.0       -1.0       -1.0   \n",
       "3         -1.0      -1.0  ...       -1.0       -1.0       -1.0       -1.0   \n",
       "4         -1.0      -1.0  ...       -1.0       -1.0       -1.0       -1.0   \n",
       "5         -1.0      -1.0  ...       -1.0       -1.0       -1.0       -1.0   \n",
       "\n",
       "judge  Judge_295  Judge_296  Judge_297  Judge_298  Judge_299  Judge_300  \n",
       "index                                                                    \n",
       "1           -1.0       -1.0       -1.0       -1.0       -1.0       -1.0  \n",
       "2           -1.0       -1.0       -1.0       -1.0       -1.0       -1.0  \n",
       "3           -1.0       -1.0       -1.0       -1.0       -1.0       -1.0  \n",
       "4           -1.0       -1.0       -1.0       -1.0       -1.0       -1.0  \n",
       "5           -1.0       -1.0       -1.0       -1.0       -1.0       -1.0  \n",
       "\n",
       "[5 rows x 300 columns]"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "t0=time.time()\n",
    "############################################################################################\n",
    "judge = np.array([[df.iloc[:,0:2].values],[df.iloc[:,2:4].values],[df.iloc[:,4:6].values]]).reshape(6000)[0::2]\n",
    "score = np.array([[df.iloc[:,0:2].values],[df.iloc[:,2:4].values],[df.iloc[:,4:6].values]]).reshape(6000)[1::2]\n",
    "df_result = pd.DataFrame({'judge':judge,'score':score}\n",
    "                         ,index=np.array([range(1,1001)]*3).reshape(3000)).reset_index()\n",
    "df_result = pd.crosstab(index=df_result['index'],columns=df_result['judge'],values=df_result['score']\n",
    "                     ,aggfunc=np.sum).fillna(-1).T.reindex(['Judge_%d'%i for i in range(1,301)]).T\n",
    "############################################################################################\n",
    "print(time.time()-t0)\n",
    "df_result.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.003553628921508789\n",
      "0.22382330894470215\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th>judge</th>\n",
       "      <th>Judge_1</th>\n",
       "      <th>Judge_2</th>\n",
       "      <th>Judge_3</th>\n",
       "      <th>Judge_4</th>\n",
       "      <th>Judge_5</th>\n",
       "      <th>Judge_6</th>\n",
       "      <th>Judge_7</th>\n",
       "      <th>Judge_8</th>\n",
       "      <th>Judge_9</th>\n",
       "      <th>Judge_10</th>\n",
       "      <th>...</th>\n",
       "      <th>Judge_291</th>\n",
       "      <th>Judge_292</th>\n",
       "      <th>Judge_293</th>\n",
       "      <th>Judge_294</th>\n",
       "      <th>Judge_295</th>\n",
       "      <th>Judge_296</th>\n",
       "      <th>Judge_297</th>\n",
       "      <th>Judge_298</th>\n",
       "      <th>Judge_299</th>\n",
       "      <th>Judge_300</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>index</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>77</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 300 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "judge Judge_1 Judge_2 Judge_3 Judge_4 Judge_5 Judge_6 Judge_7 Judge_8 Judge_9  \\\n",
       "index                                                                           \n",
       "1           1       1       1       1      77       1       1       1       1   \n",
       "2           1       1       1       1       1       1       1       1       1   \n",
       "3           1       1       1       1       1       1       1       1       1   \n",
       "4           1       1       1       1       1       1       1       1       1   \n",
       "5           1       1       1       1       1       1       1       1       1   \n",
       "\n",
       "judge Judge_10  ... Judge_291 Judge_292 Judge_293 Judge_294 Judge_295  \\\n",
       "index           ...                                                     \n",
       "1            1  ...         1         1         1         1         1   \n",
       "2            1  ...         1         1         1         1         1   \n",
       "3            1  ...         1         1         1         1         1   \n",
       "4            1  ...         1         1         1         1         1   \n",
       "5            1  ...         1         1         1         1         1   \n",
       "\n",
       "judge Judge_296 Judge_297 Judge_298 Judge_299 Judge_300  \n",
       "index                                                    \n",
       "1             1         1         1         1         1  \n",
       "2             1         1         1         1         1  \n",
       "3             1         1         1         1         1  \n",
       "4             1         1         1         1         1  \n",
       "5             1         1         1         1         1  \n",
       "\n",
       "[5 rows x 300 columns]"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "t0=time.time()\n",
    "############################################################################################\n",
    "judge = np.array([[df.iloc[:,0:2].values],[df.iloc[:,2:4].values],[df.iloc[:,4:6].values]]).reshape(6000)[0::2]\n",
    "score = np.array([[df.iloc[:,0:2].values],[df.iloc[:,2:4].values],[df.iloc[:,4:6].values]]).reshape(6000)[1::2]\n",
    "print(time.time()-t0)\n",
    "t0=time.time()\n",
    "df_result = pd.DataFrame({'judge':judge,'score':score}, dtype=str\n",
    "                         ,index=np.array([range(1,1001)]*3).reshape(3000)).reset_index()\n",
    "df_result = df_result.pivot(index='index',columns='judge'\n",
    "                    ,values='score').T.reindex(['Judge_%d'%i for i in range(1,301)]).T.fillna(1)\n",
    "############################################################################################\n",
    "print(time.time()-t0)\n",
    "df_result.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.010100603103637695\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th>评委</th>\n",
       "      <th>Judge_1</th>\n",
       "      <th>Judge_10</th>\n",
       "      <th>Judge_100</th>\n",
       "      <th>Judge_101</th>\n",
       "      <th>Judge_102</th>\n",
       "      <th>Judge_103</th>\n",
       "      <th>Judge_104</th>\n",
       "      <th>Judge_105</th>\n",
       "      <th>Judge_106</th>\n",
       "      <th>Judge_107</th>\n",
       "      <th>...</th>\n",
       "      <th>Judge_90</th>\n",
       "      <th>Judge_91</th>\n",
       "      <th>Judge_92</th>\n",
       "      <th>Judge_93</th>\n",
       "      <th>Judge_94</th>\n",
       "      <th>Judge_95</th>\n",
       "      <th>Judge_96</th>\n",
       "      <th>Judge_97</th>\n",
       "      <th>Judge_98</th>\n",
       "      <th>Judge_99</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>选手编号</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>...</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>...</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>...</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>...</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>...</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>996</th>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>...</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>997</th>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>...</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>998</th>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>...</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>999</th>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>...</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1000</th>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>...</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "      <td>-</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>1000 rows × 300 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "评委   Judge_1 Judge_10 Judge_100 Judge_101 Judge_102 Judge_103 Judge_104  \\\n",
       "选手编号                                                                      \n",
       "1          -        -         -         -         -         -         -   \n",
       "2          -        -         -         -         -         -         -   \n",
       "3          -        -         -         -         -         -         -   \n",
       "4          -        -         -         -         -         -         -   \n",
       "5          -        -         -         -         -         -         -   \n",
       "...      ...      ...       ...       ...       ...       ...       ...   \n",
       "996        -        -         -         -         -         -         -   \n",
       "997        -        -         -         -         -         -         -   \n",
       "998        -        -         -         -         -         -         -   \n",
       "999        -        -         -         -         -         -         -   \n",
       "1000       -        -         -         -         -         -         -   \n",
       "\n",
       "评委   Judge_105 Judge_106 Judge_107  ... Judge_90 Judge_91 Judge_92 Judge_93  \\\n",
       "选手编号                                ...                                       \n",
       "1            -         -         -  ...        -        -        -        -   \n",
       "2            -         -         -  ...        -        -        -        -   \n",
       "3            -         -         -  ...        -        -        -        -   \n",
       "4            -         -         -  ...        -        -        -        -   \n",
       "5            -         -         -  ...        -        -        -        -   \n",
       "...        ...       ...       ...  ...      ...      ...      ...      ...   \n",
       "996          -         -         -  ...        -        -        -        -   \n",
       "997          -         -         -  ...        -        -        -        -   \n",
       "998          -         -         -  ...        -        -        -        -   \n",
       "999          -         -         -  ...        -        -        -        -   \n",
       "1000         -         -         -  ...        -        -        -        -   \n",
       "\n",
       "评委   Judge_94 Judge_95 Judge_96 Judge_97 Judge_98 Judge_99  \n",
       "选手编号                                                        \n",
       "1           -        -        -        -        -        -  \n",
       "2           -        -        -        -        -        -  \n",
       "3           -        -        -        -        -        -  \n",
       "4           -        -        -        -        -        -  \n",
       "5           -        -        -        -        -        -  \n",
       "...       ...      ...      ...      ...      ...      ...  \n",
       "996         -        -        -        -        -        -  \n",
       "997         -        -        -        -        -        -  \n",
       "998         -        -        -        -        -        -  \n",
       "999         -        -        -        -        -        -  \n",
       "1000        -        -        -        -        -        -  \n",
       "\n",
       "[1000 rows x 300 columns]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.16326904296875\n"
     ]
    }
   ],
   "source": [
    "t0=time.time()\n",
    "############################################################################################\n",
    "df_result = pd.concat([df.iloc[:, i:i+2].rename(columns=lambda x:x[:-1]) for i in range(0, df.shape[1], 2)]).reset_index()\n",
    "df_result['打分'] = df_result['打分'].astype(str)\n",
    "print(time.time()-t0)\n",
    "t0=time.time()\n",
    "df_result = df_result.pivot(index='选手编号', columns='评委', values='打分').fillna('-')\n",
    "display(df_result)\n",
    "df_result = df_result[sorted(df_result.columns, key=lambda x:int(x.split('_')[-1]))]\n",
    "df_result.head()\n",
    "############################################################################################\n",
    "print(time.time()-t0)\n",
    "#df_result.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Judge_1',\n",
       " 'Judge_2',\n",
       " 'Judge_3',\n",
       " 'Judge_4',\n",
       " 'Judge_5',\n",
       " 'Judge_6',\n",
       " 'Judge_7',\n",
       " 'Judge_8',\n",
       " 'Judge_9',\n",
       " 'Judge_10',\n",
       " 'Judge_11',\n",
       " 'Judge_12',\n",
       " 'Judge_13',\n",
       " 'Judge_14',\n",
       " 'Judge_15',\n",
       " 'Judge_16',\n",
       " 'Judge_17',\n",
       " 'Judge_18',\n",
       " 'Judge_19',\n",
       " 'Judge_20',\n",
       " 'Judge_21',\n",
       " 'Judge_22',\n",
       " 'Judge_23',\n",
       " 'Judge_24',\n",
       " 'Judge_25',\n",
       " 'Judge_26',\n",
       " 'Judge_27',\n",
       " 'Judge_28',\n",
       " 'Judge_29',\n",
       " 'Judge_30',\n",
       " 'Judge_31',\n",
       " 'Judge_32',\n",
       " 'Judge_33',\n",
       " 'Judge_34',\n",
       " 'Judge_35',\n",
       " 'Judge_36',\n",
       " 'Judge_37',\n",
       " 'Judge_38',\n",
       " 'Judge_39',\n",
       " 'Judge_40',\n",
       " 'Judge_41',\n",
       " 'Judge_42',\n",
       " 'Judge_43',\n",
       " 'Judge_44',\n",
       " 'Judge_45',\n",
       " 'Judge_46',\n",
       " 'Judge_47',\n",
       " 'Judge_48',\n",
       " 'Judge_49',\n",
       " 'Judge_50',\n",
       " 'Judge_51',\n",
       " 'Judge_52',\n",
       " 'Judge_53',\n",
       " 'Judge_54',\n",
       " 'Judge_55',\n",
       " 'Judge_56',\n",
       " 'Judge_57',\n",
       " 'Judge_58',\n",
       " 'Judge_59',\n",
       " 'Judge_60',\n",
       " 'Judge_61',\n",
       " 'Judge_62',\n",
       " 'Judge_63',\n",
       " 'Judge_64',\n",
       " 'Judge_65',\n",
       " 'Judge_66',\n",
       " 'Judge_67',\n",
       " 'Judge_68',\n",
       " 'Judge_69',\n",
       " 'Judge_70',\n",
       " 'Judge_71',\n",
       " 'Judge_72',\n",
       " 'Judge_73',\n",
       " 'Judge_74',\n",
       " 'Judge_75',\n",
       " 'Judge_76',\n",
       " 'Judge_77',\n",
       " 'Judge_78',\n",
       " 'Judge_79',\n",
       " 'Judge_80',\n",
       " 'Judge_81',\n",
       " 'Judge_82',\n",
       " 'Judge_83',\n",
       " 'Judge_84',\n",
       " 'Judge_85',\n",
       " 'Judge_86',\n",
       " 'Judge_87',\n",
       " 'Judge_88',\n",
       " 'Judge_89',\n",
       " 'Judge_90',\n",
       " 'Judge_91',\n",
       " 'Judge_92',\n",
       " 'Judge_93',\n",
       " 'Judge_94',\n",
       " 'Judge_95',\n",
       " 'Judge_96',\n",
       " 'Judge_97',\n",
       " 'Judge_98',\n",
       " 'Judge_99',\n",
       " 'Judge_100',\n",
       " 'Judge_101',\n",
       " 'Judge_102',\n",
       " 'Judge_103',\n",
       " 'Judge_104',\n",
       " 'Judge_105',\n",
       " 'Judge_106',\n",
       " 'Judge_107',\n",
       " 'Judge_108',\n",
       " 'Judge_109',\n",
       " 'Judge_110',\n",
       " 'Judge_111',\n",
       " 'Judge_112',\n",
       " 'Judge_113',\n",
       " 'Judge_114',\n",
       " 'Judge_115',\n",
       " 'Judge_116',\n",
       " 'Judge_117',\n",
       " 'Judge_118',\n",
       " 'Judge_119',\n",
       " 'Judge_120',\n",
       " 'Judge_121',\n",
       " 'Judge_122',\n",
       " 'Judge_123',\n",
       " 'Judge_124',\n",
       " 'Judge_125',\n",
       " 'Judge_126',\n",
       " 'Judge_127',\n",
       " 'Judge_128',\n",
       " 'Judge_129',\n",
       " 'Judge_130',\n",
       " 'Judge_131',\n",
       " 'Judge_132',\n",
       " 'Judge_133',\n",
       " 'Judge_134',\n",
       " 'Judge_135',\n",
       " 'Judge_136',\n",
       " 'Judge_137',\n",
       " 'Judge_138',\n",
       " 'Judge_139',\n",
       " 'Judge_140',\n",
       " 'Judge_141',\n",
       " 'Judge_142',\n",
       " 'Judge_143',\n",
       " 'Judge_144',\n",
       " 'Judge_145',\n",
       " 'Judge_146',\n",
       " 'Judge_147',\n",
       " 'Judge_148',\n",
       " 'Judge_149',\n",
       " 'Judge_150',\n",
       " 'Judge_151',\n",
       " 'Judge_152',\n",
       " 'Judge_153',\n",
       " 'Judge_154',\n",
       " 'Judge_155',\n",
       " 'Judge_156',\n",
       " 'Judge_157',\n",
       " 'Judge_158',\n",
       " 'Judge_159',\n",
       " 'Judge_160',\n",
       " 'Judge_161',\n",
       " 'Judge_162',\n",
       " 'Judge_163',\n",
       " 'Judge_164',\n",
       " 'Judge_165',\n",
       " 'Judge_166',\n",
       " 'Judge_167',\n",
       " 'Judge_168',\n",
       " 'Judge_169',\n",
       " 'Judge_170',\n",
       " 'Judge_171',\n",
       " 'Judge_172',\n",
       " 'Judge_173',\n",
       " 'Judge_174',\n",
       " 'Judge_175',\n",
       " 'Judge_176',\n",
       " 'Judge_177',\n",
       " 'Judge_178',\n",
       " 'Judge_179',\n",
       " 'Judge_180',\n",
       " 'Judge_181',\n",
       " 'Judge_182',\n",
       " 'Judge_183',\n",
       " 'Judge_184',\n",
       " 'Judge_185',\n",
       " 'Judge_186',\n",
       " 'Judge_187',\n",
       " 'Judge_188',\n",
       " 'Judge_189',\n",
       " 'Judge_190',\n",
       " 'Judge_191',\n",
       " 'Judge_192',\n",
       " 'Judge_193',\n",
       " 'Judge_194',\n",
       " 'Judge_195',\n",
       " 'Judge_196',\n",
       " 'Judge_197',\n",
       " 'Judge_198',\n",
       " 'Judge_199',\n",
       " 'Judge_200',\n",
       " 'Judge_201',\n",
       " 'Judge_202',\n",
       " 'Judge_203',\n",
       " 'Judge_204',\n",
       " 'Judge_205',\n",
       " 'Judge_206',\n",
       " 'Judge_207',\n",
       " 'Judge_208',\n",
       " 'Judge_209',\n",
       " 'Judge_210',\n",
       " 'Judge_211',\n",
       " 'Judge_212',\n",
       " 'Judge_213',\n",
       " 'Judge_214',\n",
       " 'Judge_215',\n",
       " 'Judge_216',\n",
       " 'Judge_217',\n",
       " 'Judge_218',\n",
       " 'Judge_219',\n",
       " 'Judge_220',\n",
       " 'Judge_221',\n",
       " 'Judge_222',\n",
       " 'Judge_223',\n",
       " 'Judge_224',\n",
       " 'Judge_225',\n",
       " 'Judge_226',\n",
       " 'Judge_227',\n",
       " 'Judge_228',\n",
       " 'Judge_229',\n",
       " 'Judge_230',\n",
       " 'Judge_231',\n",
       " 'Judge_232',\n",
       " 'Judge_233',\n",
       " 'Judge_234',\n",
       " 'Judge_235',\n",
       " 'Judge_236',\n",
       " 'Judge_237',\n",
       " 'Judge_238',\n",
       " 'Judge_239',\n",
       " 'Judge_240',\n",
       " 'Judge_241',\n",
       " 'Judge_242',\n",
       " 'Judge_243',\n",
       " 'Judge_244',\n",
       " 'Judge_245',\n",
       " 'Judge_246',\n",
       " 'Judge_247',\n",
       " 'Judge_248',\n",
       " 'Judge_249',\n",
       " 'Judge_250',\n",
       " 'Judge_251',\n",
       " 'Judge_252',\n",
       " 'Judge_253',\n",
       " 'Judge_254',\n",
       " 'Judge_255',\n",
       " 'Judge_256',\n",
       " 'Judge_257',\n",
       " 'Judge_258',\n",
       " 'Judge_259',\n",
       " 'Judge_260',\n",
       " 'Judge_261',\n",
       " 'Judge_262',\n",
       " 'Judge_263',\n",
       " 'Judge_264',\n",
       " 'Judge_265',\n",
       " 'Judge_266',\n",
       " 'Judge_267',\n",
       " 'Judge_268',\n",
       " 'Judge_269',\n",
       " 'Judge_270',\n",
       " 'Judge_271',\n",
       " 'Judge_272',\n",
       " 'Judge_273',\n",
       " 'Judge_274',\n",
       " 'Judge_275',\n",
       " 'Judge_276',\n",
       " 'Judge_277',\n",
       " 'Judge_278',\n",
       " 'Judge_279',\n",
       " 'Judge_280',\n",
       " 'Judge_281',\n",
       " 'Judge_282',\n",
       " 'Judge_283',\n",
       " 'Judge_284',\n",
       " 'Judge_285',\n",
       " 'Judge_286',\n",
       " 'Judge_287',\n",
       " 'Judge_288',\n",
       " 'Judge_289',\n",
       " 'Judge_290',\n",
       " 'Judge_291',\n",
       " 'Judge_292',\n",
       " 'Judge_293',\n",
       " 'Judge_294',\n",
       " 'Judge_295',\n",
       " 'Judge_296',\n",
       " 'Judge_297',\n",
       " 'Judge_298',\n",
       " 'Judge_299',\n",
       " 'Judge_300']"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sorted(df_result.columns, key=lambda x:int(x.split('_')[-1]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>选手编号</th>\n",
       "      <th>评委</th>\n",
       "      <th>打分</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>Judge_248</td>\n",
       "      <td>75</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>Judge_39</td>\n",
       "      <td>60</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>Judge_244</td>\n",
       "      <td>99</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>Judge_163</td>\n",
       "      <td>76</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>Judge_206</td>\n",
       "      <td>70</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2995</th>\n",
       "      <td>996</td>\n",
       "      <td>Judge_62</td>\n",
       "      <td>41</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2996</th>\n",
       "      <td>997</td>\n",
       "      <td>Judge_214</td>\n",
       "      <td>81</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2997</th>\n",
       "      <td>998</td>\n",
       "      <td>Judge_286</td>\n",
       "      <td>39</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2998</th>\n",
       "      <td>999</td>\n",
       "      <td>Judge_79</td>\n",
       "      <td>89</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2999</th>\n",
       "      <td>1000</td>\n",
       "      <td>Judge_220</td>\n",
       "      <td>64</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>3000 rows × 3 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "      选手编号         评委  打分\n",
       "0        1  Judge_248  75\n",
       "1        2   Judge_39  60\n",
       "2        3  Judge_244  99\n",
       "3        4  Judge_163  76\n",
       "4        5  Judge_206  70\n",
       "...    ...        ...  ..\n",
       "2995   996   Judge_62  41\n",
       "2996   997  Judge_214  81\n",
       "2997   998  Judge_286  39\n",
       "2998   999   Judge_79  89\n",
       "2999  1000  Judge_220  64\n",
       "\n",
       "[3000 rows x 3 columns]"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.concat([df.iloc[:, i:i+2].rename(columns=lambda x:x[:-1]) for i in range(0, df.shape[1], 2)]).reset_index()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
